package weeek11.topic10;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class HllTest {
    public static void main(String[] args) {
        JedisPool jedisPool = JedisPoolUtil.getJedisPool();
        String hllKey = "test_hll";
        try (Jedis jedis = jedisPool.getResource()) {
            jedis.del(hllKey);
            //init 0-1000个用户点击了1次 0-500个用户点击了2次，最后计数为1000
            for (int i = 0; i < 1000; i++) {
                jedis.pfadd(hllKey,String.valueOf(i));
            }
            for (int i = 0; i < 500; i++) {
                jedis.pfadd(hllKey,String.valueOf(i));
            }
            System.out.println("计数:" + jedis.pfcount(hllKey));
        }
    }
}
